Cellular Organization of Barrel Cortex

Comparison of CUBIC mount, ScaleSQ, and TDE

The "CUBIC mount" was originally developed by Lee et al., 2015, and is derived from the original CUBIC technique (Susaki et. al, 2015). The fixed brain was rapidly cleared in this solution.

This mounting medium was compared with ScaleSQ and TDE in PBS, other rapid tissue-clearing techniques.

First, coronal slices were imaged after clearing with various solutions. Here are the settings for imaging:

Camera: Leica MC 120HD

Microscope: Leica MZ 10F

White balance: 38, 32, 0 (red, blue, black)

Exposure: 91

Gain: 107

Brightness: 127

Gamma: 0.55

The coronal slices (750 um) from TK563 were cleared with cubic mounting medium, 47% TDE, 60% TED, ScaleSQ(5) followed by ScaleS4(0). The room temperature was 23.3 C (12:00 23.3.2017).

In [49]:
# summary fig for the comparison of rapid brain-clearing techniques

methods = ['cubic mount', 'ScaleSQ(0)', 'ScaleSQ(5)', 'TDE 47%', 'TDE 60%']
times = ['before', '4h', '2d']
slice_num = [6, 7, 3, 4, 5]
fig = plt.figure(figsize=(6.85, 8))
gs1 = gridspec.GridSpec(5, 3, left=0.03, right=0.45, bottom=0.26, wspace=0, hspace=0.02)
width = 1368
height = 1400
rot = [[0, 0, 0], [0, -86, -90], [0, -93, -88], [0, -1.5, 0], [2, 0, 0]]
x_offset = [[0, 200, 100], [200, 100, 0], [450, 150, 0], [600, 400, 100], [400, 350, 400]]
y_offset = [[0, 0, 0], [0, 385, 200], [0, 370, 300], [0, 0, 0], [0, -20, 20]]
for i in range(5):
    for j, d in enumerate([0, 1, 3]):
        ax = fig.add_subplot(gs1[i, j], axisbg='k')
        img = rotate(mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK565/Anatomy/slice{}_{}.JPG".format(slice_num[i], d)), rot[i][j])
        ax.imshow(img)
        ax.set_xlim((x_offset[i][j], x_offset[i][j] + 1250))
        ax.set_ylim((y_offset[i][j] + height, y_offset[i][j]))
        ax.set_xticks([])
        ax.set_yticks([])
        if j == 0:
            ax.set_ylabel(methods[i])
        if i == 0:
            ax.set_title(times[j])
        
        with open("C:/Users/kiritani/Documents/data/cells/TK565/Anatomy/slice{}_{}.roi".format(slice_num[i], d), "rb") as f:
                roi = ijroi.read_roi(f)
                roi_rotated = (roi[:, 1] - 912 + (roi[:, 0] - 684) * 1j) * rect(1, rot[i][j] / -180 * np.pi) + complex(img.shape[1], img.shape[0])/2
                ax.plot([r.real for r in roi_rotated], [r.imag for r in roi_rotated])
ax.plot([1050, 1050 + 2 / scale_factor], [1350, 1350], 'white', lw=3) # scale bar of 2 mm


ax = fig.add_axes([0.07, 0.13, 0.4, 0.1], #aspect=68)
                 )
slices_grouped = {}
for method in methods:
    slices = [s for s in slicesTK563 if s['method'] == method] + [s for s in slicesTK565 if s['method'] == method]
    slices_grouped = [s['area']/s['area'][0] for s in slices]
    size = []
    std = []
    for i in range(11):
        size.append(np.mean([cn[i] for cn in slices_grouped]))
        std.append(np.std([cn[i] for cn in slices_grouped]))
    p = ax.plot([0, 4] +  list(range(24, 24 * 10, 24)), size, label=method)
    ax.errorbar([0, 4] +  list(range(24, 24 * 10, 24)), size, yerr=std, color=p[0].get_color())

ax.set_xticks([4, 24 * 3, 24 * 6, 24 * 9])
ax.set_xticklabels(['4h', '3d', '6d', '9d'])
ax.set_yticks([0.5, 1, 1.5])
ax.set_ylabel('normalized brain area')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.set_xlim((0, 24 * 11))
handles,labels = ax.get_legend_handles_labels()
handles = [handles[2], handles[1], handles[0], handles[3], handles[4]]
labels = [labels[2], labels[1], labels[0], labels[3], labels[4]]
leg = ax.legend(handles, labels, bbox_to_anchor=(.82, 1), loc=2, borderaxespad=0., columnspacing=2,fontsize=6, frameon=False, handlelength=1)

gs2 = gridspec.GridSpec(6, 3, width_ratios=[1, 1, 0.5], left=0.52, right=0.97, wspace=0, hspace=0.02)
surface_frame = [3, 7, 5, 3, 7, 4, 7, 4]
bottom_frame = [100, None, 127, None, None, None, None, None]
vmin = 0
vmax = 60
slice_nums = [4, 5, 3, 10, 2, 9]
for i, slice_num in enumerate(slice_nums):
    img = tifffile.imread("C:/Users/kiritani/Documents/data/cells/TK567/Anatomy/slice{}_stack.lsm".format(slice_num))
    ax_25 = fig.add_subplot(gs2[i, 0])
    ax_25.imshow(img[0, 0, surface_frame[i] + 5], vmin=vmin, vmax=vmax, cmap='gray') # 5 * 5 = 25 um deep
    ax_25.set_xticks([])
    ax_25.set_yticks([])
    ax_25.set_ylabel((methods + ['PBS'])[i])
    ax_400 = fig.add_subplot(gs2[i, 1])
    ax_400.imshow(img[0, 0, surface_frame[i] + 80], vmin=vmin, vmax=vmax, cmap='gray') # 400 um deep
    ax_400.set_xticks([])
    ax_400.set_yticks([])
    side = np.amax(img[0, 0], 1)#[:100,:]
    side = np.concatenate([side, np.ones((138 - img.shape[2], 512)).astype(int) * 0])[:130, :]
    ax_side = fig.add_subplot(gs2[i, 2])
    ax_side.imshow(side, vmin=vmin, vmax=vmax, cmap='gray', )
    if bottom_frame[i]:
        ax_side.axhline(bottom_frame[i], color='yellow')
    ax_side.set_aspect(5 / 0.625169)
    ax_side.set_axis_off()
    if i == 0:
        ax_25.set_title('z = 25 um')
        ax_400.set_title('z = 400 um')
        ax_side.set_title('side view')
ax_400.autoscale(False)
ax_400.plot([300, 300 + 50 / 0.625169], [450, 450], 'white', lw=3)
#ax_400.text(320, 400, '50 um', color='white')
ax_side.autoscale(False)
ax_side.plot([250, 250 + 100 / 0.625169], [100, 100], 'white', lw=3);
#ax_side.text(320, 80, '50 um', color='white');

Distribution of specific neurons in barrel cortex

Four mouse lines

  • Scnn1a_Cre X Rosa_LSL_tdTomato
  • PV_IRES_Cre X Rosa_LSL_tdTomato
  • SOM_IRES_Cre X Rosa_LSL_tdTomato
  • VIP_IRES_Cre X Rosa_LSL_tdTomato
In [54]:
connectivity = mpimg.imread("data/images/connectivity.png")
fig = plt.figure(frameon=False)
ax = fig.add_axes([0, 0, 1, 1])
ax.axis('off')
ax.imshow(connectivity);

Coronal and tangential slices

In [3]:
f, axarr = plt.subplots(1, 4, figsize=(12, 8))
image = tifffile.imread('data/images/TK513/slide2_slice1_epi_tdTomato_Fused.tif')
pixel_size = 895.26 / 1388 # in um/pixel
bar200um = 200 / pixel_size
axarr[0].imshow(rotate(image[:, 0:3000], 140)[1120:3320, 1500:2500], cmap='gray', vmin=0, vmax=60)
axarr[0].autoscale(False)
axarr[0].axis('off')
axarr[0].set_title('Scnn1a', color='brown');

image = tifffile.imread('data/images/TK478/slide1_slice5_epi_tdTomato_Fused.tif')
axarr[1].imshow(rotate(image, 120)[1700:3900, 1500:2500], cmap='gray', vmin=0, vmax=48)
axarr[1].autoscale(False)
axarr[1].plot([100, bar200um + 100], [2050, 2050], color='w')
axarr[1].axis('off')
axarr[1].set_title('PV', color='red');

image = tifffile.imread('data/images/TK508/slide3_slice3_epi_tdTomato_Fused.tif')
axarr[2].imshow(rotate(image, 145)[1700:3900, 2000:3000], cmap='gray')
axarr[2].autoscale(False)
axarr[2].axis('off')
axarr[2].set_title('Sst', color='orange');

image = tifffile.imread('data/images/TK460/slide2_slice1_epi_tdTomato_Fused.tif')
axarr[3].imshow(np.fliplr(rotate(image, 200))[1300:3500, 2500:3500], cmap='gray', vmin=0, vmax=48)
axarr[3].autoscale(False)
plt.axis('off')
axarr[3].set_title('VIP', color='deepskyblue');

plt.savefig('coronal_slices.png', dpi=200, bbox_inches='tight')
In [60]:
f, axarr = plt.subplots(3, 2, figsize=(12, 14))

image = tifffile.imread('data/images/TK499/slice7_epi_tdTomato_Fused.tif') # this image is inverted (by the upright microscope), the actual slice is not. Seen from the top.
image = image[1000:, 0:5500]
image = np.flipud(image)
axarr[0, 0].imshow(image, cmap='gray')
pixel_size = 895.26 / 1388 # in um/pixel
bar200um = 200 / pixel_size
#plt.plot([3000, bar200um + 3000], [100, 100], color='w')
axarr[0, 0].set_title('Scnn1a', color='brown')

image = tifffile.imread('data/images/TK534/slice4_fused.tif')
axarr[0, 1].imshow(np.flipud(rotate(image, 180)[250:, :]), cmap='gray', vmin=0, vmax=47)
#plt.plot([10, bar200um + 10], [300, 300], color='w')
axarr[0, 1].set_title('PV', color='red')

image = tifffile.imread('data/images/TK525/slice6_epi_tdTomato_Fused.tif')
axarr[1, 0].imshow(image[1000:, 0:5500], cmap='gray', vmin=0, vmax=60)
#plt.plot([10, bar200um + 10], [300, 300], color='w')
axarr[1, 0].set_title('Sst', color='orange');

image = tifffile.imread('data/images/TK543/slice5_epi_tdTomato.tif')
axarr[1, 1].imshow(rotate(image, -145)[2800:6400, 2000:7200], cmap='gray', vmin=0, vmax=30) # this slice imaged from the bottom side
axarr[1, 1].set_title('VIP', color='deepskyblue');

image = tifffile.imread('data/images/TK525/slice6_epi_gfp_Fused.tif')
axarr[2, 0].imshow(image[1000:, 0:5500], cmap='gray')
#plt.plot([10, bar200um + 10], [300, 300], color='w')
axarr[2, 0].set_title('Autofluorescence');

image = tifffile.imread('data/images/TK543/slice5_epi_green_auto.tif')
axarr[2, 1].imshow(rotate(image, -145)[2800:6400, 2000:7200], cmap='gray', vmin=0, vmax=30)
axarr[2, 1].set_title('Autofluorescence');

for axrow in axarr:
    for ax in axrow:
        ax.autoscale(False)
        ax.plot([10, bar200um + 10], [300, 300], color='w')
        ax.axis('off')
plt.savefig('tangential_slices.png', dpi=200, bbox_inches='tight')

Imaging of whole C2 column

utility functions for this section
In [7]:
def stack2movie(stack, step_size, pia=0, text_position=(850, 900), contrast=(1, 99)):
    """Converts an image stack to a movie. The first dimension of the stack is for z."""
    fig, ax = plt.subplots()
    ax.set_position([0,0,1,1])
    ax.set_axis_off()
    im = ax.imshow(stack[0, :, :], 'gray')
    tx = ax.text(*text_position, '', color='r')
    def init():
        im.set_data(stack[0, :, :])
        return [im]

    def animate(i):
        im.set_array(stack[i, :, :])
        im.set_clim(vmin=np.percentile(stack[i, :, :], contrast[0]), vmax=np.percentile(stack[i, :, :], contrast[1]))
        tx.set_text('{0:.1f} um'.format((i - pia) * step_size))
        return [im]

    anim = animation.FuncAnimation(fig, animate, init_func=init, frames=stack.shape[0], interval=500, blit=False)
    return anim

def prepare_fig():
    fig = plt.figure(figsize=(6.85, 8.5))
    gs1 = gridspec.GridSpec(1, 3, left=0.05, right=1, bottom=0.68, wspace=0, hspace=0)
    ax_l4_large = fig.add_subplot(gs1[0, :-1])
    #ax_l4_large.set_axis_off()
    ax_whisker_pad = fig.add_subplot(gs1[0, -1])
    #ax_whisker_pad.set_axis_off()
    low_bottom = 0.04
    low_top = 0.66
    ax_side_view = fig.add_axes([0.05, low_bottom, 0.3, low_top - low_bottom], )
    ax_side_view.yaxis.tick_right()
    gs2 = gridspec.GridSpec(3, 2, bottom=low_bottom, top=low_top, left=0.4, right=1, hspace=0.03, wspace=0.01)
    return (fig, gs1, ax_l4_large, ax_whisker_pad, ax_side_view, gs2)

def tri_indices(simplices):
    #simplices is a numpy array defining the simplices of the triangularization
    #returns the lists of indices i, j, k
    
    return ([triplet[c] for triplet in simplices] for c in range(3))

def plotly_trisurf(x, y, z, simplices, plot_edges=None):
    #x, y, z are lists of coordinates of the triangle vertices 
    #simplices are the simplices that define the triangularization;
    #simplices  is a numpy array of shape (no_triangles, 3)
    #insert here the  type check for input data
    from functools import reduce
    #from go import Data
    from plotly.graph_objs import Data
    
    points3D=np.vstack((x,y,z)).T
    tri_vertices=map(lambda index: points3D[index], simplices)# vertices of the surface triangles     
    zmean=[np.mean(tri[:,2]) for tri in tri_vertices ]# mean values of z-coordinates of 
                                                      #triangle vertices
    min_zmean=np.min(zmean)
    max_zmean=np.max(zmean)  
    #facecolor=[map_z2color(zz,  colormap, min_zmean, max_zmean) for zz in zmean] 
    I,J,K=tri_indices(simplices)
    
    triangles=go.Mesh3d(x=x,
                     y=y,
                     z=z, 
                     i=I,
                     j=J,
                     k=K,
                     name='',
                        opacity=0.5
                    )
    
    if plot_edges is None:# the triangle sides are not plotted 
        return Data([triangles])
    else:
        #define the lists Xe, Ye, Ze, of x, y, resp z coordinates of edge end points for each triangle
        #None separates data corresponding to two consecutive triangles
        lists_coord=[[[T[k%3][c] for k in range(4)]+[ None]   for T in tri_vertices]  for c in range(3)]
        Xe, Ye, Ze=[reduce(lambda x,y: x+y, lists_coord[k]) for k in range(3)]
        
        #define the lines to be plotted
        lines=Scatter3d(x=Xe,
                        y=Ye,
                        z=Ze,
                        mode='lines',
                        line=Line(color= 'rgb(50,50,50)', width=1.5)
               )
        return Data([triangles, lines])

Preparation of thick slices

1.5 mm tangential slices of the left hemisphere were cut and cleared in CUBIC mount. The barrel cortex was imaged with confocal and 2p microscopes.

In [66]:
1//2
Out[66]:
0
In [82]:
fig, axes = plt.subplots(2, 4, gridspec_kw={'left': 0, 'right': 1, 'wspace': 0, 'hspace':0.05})

mice = ('TK601', 'TK577', 'TK592', 'TK589')
files = (('MC120061.JPG', 'MC120062.JPG'), ('MC120064.JPG', 'MC120065.JPG'), ('MC120071.JPG', 'MC120072.JPG'), ('MC120073.JPG', 'MC120074.JPG'))

i = 0
for m, fpairs in zip(mice, files): 
    for f in fpairs:
        im = mpimg.imread('C:/Users/kiritani/Documents/data/cells/' + m + '/Anatomy/' + f)
        ax = axes[i%2, i//2]
        ax.imshow(np.rot90(im))
        ax.set_axis_off()
        i += 1
        if i%2:
            mouse_lines = ('Scnn1a', 'PV', 'Sst', 'VIP')
            ax.set_title(mouse_lines[i//2])

Scnn1a

Mouse TK566
figure
In [10]:
L4barrels = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK566/Anatomy/stack_tile_1.lsm')
whisker_pad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK566/Anatomy/whisker_pad/MC120056.JPG")
c2_stack = tifffile.imread("C:/Users/kiritani/Documents/data/cells/Tk566/Anatomy/rotated_stack_tdtom.ome.tif")

The following imagej macro was used to rotate the original confocal image and save the data in .ome.tif.

open("C:\Users\kiritani\Documents\data\cells\TK566\Anatomy\stack_tdtom.lsm");
run("Rotate... ", "angle=26 grid=1 interpolation=Bilinear enlarge stack");
run("Reslice [/]...", "output=0.6251697 start=Top");
run("Rotate... ", "angle=-9 grid=1 interpolation=Bilinear enlarge stack");
run("Reslice [/]...", "output=0.6251697 start=Top");
run("Bio-Formats Exporter", "save=C:\Users\kiritani\Documents\data\cells\TK566\Anatomy\rotated_stack_tdtom.ome.tif
export compression=Uncompressed");

In [18]:
scale_factor = 5 / distance.euclidean([1541, 430], [1558, 1171])
In [49]:
fig = plt.figure(figsize=(6.85, 8.5))
gs1 = gridspec.GridSpec(1, 3, left=0.05, right=1, bottom=0.68, wspace=0, hspace=0)
ax_l4_large = fig.add_subplot(gs1[0, :-1])
ax_l4_large.imshow(L4barrels[0, 0, 3, :, :], 'gray')
pixel_size = 2.5007 # in um
bar300um = 300 / pixel_size
ax_l4_large.plot([1200, 1200 + bar300um], [200, 200], color='y')
ax_l4_large.set_xlim((0, L4barrels.shape[4]))
ax_l4_large.set_ylim((1000, 180))
ax_l4_large.set_axis_off()
ax_whisker_pad = fig.add_subplot(gs1[0, -1])
ax_whisker_pad.imshow(whisker_pad)
ax_whisker_pad.text(920, 750, r'$\beta$', color='r')
ax_whisker_pad.text(1120, 750, 'B1', color='r')
ax_whisker_pad.text(1250, 750, 'B2', color='r')
ax_whisker_pad.text(1390, 770, 'B3', color='r')
ax_whisker_pad.plot([1400, 1400 + 2/scale_factor], [500, 500], color='y')
ax_whisker_pad.set_xlim((700, 1800))
ax_whisker_pad.set_ylim(1200, 200)
ax_whisker_pad.set_axis_off()
low_bottom = 0.04
low_top = 0.66
ax_side_view = fig.add_axes([0.07, low_bottom, 0.3, low_top - low_bottom], )
ax_side_view.imshow(c2_stack[:, 700, :], 'gray')
ax_side_view.set_xlim((500, 1100))
ax_side_view.set_ylim((1800, 180))
ax_side_view.axhline(200, color='y', linestyle='--')
ax_side_view.plot([500, 600, 700, 800, 900, 1000, 1100], [1800, 1750, 1702, 1690, 1665, 1654, 1648], color='y', linestyle='--')
ax_side_view.set_xticks([])
ax_side_view.yaxis.tick_right()
ax_side_view.yaxis.set_tick_params(direction='in', pad=0)
depths = [296, 545, 960, 1219, 1527, 1685]
ax_side_view.set_yticks(depths)
ax_side_view.set_yticklabels(['<' for i in range(len(depths))], color='r')
pixel_size_bottom = 0.6251697
ax_side_view.plot([900, 900 + 100 / pixel_size_bottom], [1500, 1500], color='y')
gs2 = gridspec.GridSpec(3, 2, bottom=low_bottom, top=low_top, left=0.4, right=1, hspace=0.03, wspace=0.01)
for i, depth in enumerate([296, 545, 960, 1219, 1527, 1685]):
    ax = fig.add_subplot(gs2[i%3, i >2])
    ax.imshow(rotate(c2_stack[depth], 26)[680:1430, 600:1500], 'gray')
    ax.set_axis_off()
ax.autoscale(False)
ax.plot([600, 600 + 100 / pixel_size_bottom], [700, 700], color='y')
Out[49]:
[<matplotlib.lines.Line2D at 0x1e91f1b2e8>]
In [62]:
stack_raw = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK566/Anatomy/stack_tdtom.lsm').squeeze()
anim = stack2movie(stack_raw, step_size=2.925)
anim.save('TK566.mp4', writer='ffmpeg', codec='h264', dpi=300)
In [11]:
%%HTML
<video controls>
  <source src="TK566.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>
In [50]:
YouTubeVideo("ZmTBzTc-0VE")
Out[50]:
In [35]:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for roi in rois.items():
    ax.plot(roi[1]['x'], roi[1]['y'], roi[1]['position'], 'b', linewidth=0.4)
Mouse TK580
In [5]:
L4barrel = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK580/Anatomy/tile_z_267-517.lsm')
td_2p_image = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK580/Anatomy/stack_tdtom.lsm')
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK580/Anatomy/whisker_pad/MC120054.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(800, 590, r'$\beta$', color='r')
plt.text(920, 570, 'B1', color='r')
plt.text(1040, 600, 'B2', color='r')
plt.text(1160, 605, 'B3', color='r')
plt.figure()
plt.imshow(L4barrel[0, 0, 2])
Out[5]:
<matplotlib.image.AxesImage at 0xbc3897b4a8>
Mouse TK581
In [13]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK581/Anatomy/whisker_pad/MC120058.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(550, 800, r'$\beta$', color='r')
plt.text(670, 725, 'B1', color='r')
plt.text(780, 725, 'B2', color='r')
plt.text(930, 720, 'B3', color='r')
plt.text(1050, 720, 'B4', color='r')
Out[13]:
<matplotlib.text.Text at 0xb5f679f4e0>
Mouse TK601
In [54]:
L4barrels = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK601/Anatomy/tile525.ome.tif') # converted from a czi file.
whisker_pad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK601/Anatomy/whisker_pad/MC120062.JPG")
c2_stack = tifffile.imread("C:/Users/kiritani/Documents/data/cells/Tk601/Anatomy/stack0-1276p91.ome.tif")
In [16]:
c2_stack.shape
Out[16]:
(2175, 1278, 1576)
In [24]:
anim.save('TK601.mp4', writer='ffmpeg', codec='h264', bitrate=10000)
In [51]:
YouTubeVideo("DeiYTgsGqDs")
Out[51]:
In [56]:
fig = plt.figure(figsize=(6.85, 8))
gs1 = gridspec.GridSpec(1, 3, left=0.05, right=1, bottom=0.7, wspace=0, hspace=0)
ax_l4_large = fig.add_subplot(gs1[0, :-1])
ax_l4_large.imshow(rotate(L4barrels, 135), 'gray')
ax_l4_large.set_ylim((4000, 1200))
ax_l4_large.set_xlim((100, 4300))
ax_l4_large.set_axis_off()
ax_whisker_pad = fig.add_subplot(gs1[0, -1])
ax_whisker_pad.imshow(whisker_pad)
ax_whisker_pad.text(530, 790, r'$\beta$', color='r')
ax_whisker_pad.text(650, 780, 'B1', color='r')
ax_whisker_pad.text(800, 750, 'B2', color='r')
ax_whisker_pad.text(950, 800, 'B3', color='r')
ax_whisker_pad.set_xlim((200, 1400))
ax_whisker_pad.set_ylim(top=200)
ax_whisker_pad.set_axis_off()
low_bottom = 0.04
low_top = 0.66
ax_side_view = fig.add_axes([0.07, low_bottom, 0.3, low_top - low_bottom], )
ax_side_view.imshow(c2_stack[:, 700, :], 'gray', aspect=3.3252872/0.2932506)
ax_side_view.set_ylim((385, 0))
ax_side_view.yaxis.tick_right()
ax_side_view.yaxis.set_tick_params(direction='in', pad=0)
depths = [29, 84, 163, 232, 264, 287,]
ax_side_view.set_yticks(depths)
ax_side_view.set_yticklabels(['<' for i in range(len(depths))], color='r')
ax_side_view.set_xticks([])
vmaxs = []
vmins = []
gs2 = gridspec.GridSpec(3, 2, top=low_top, bottom=low_bottom, left=0.4, right=1, hspace=0.03, wspace=0.01)
for i, depth in enumerate(depths):
    ax = fig.add_subplot(gs2[i%3, i >2])
    vmin = np.percentile(c2_stack[depth], 1)
    vmax = np.percentile(c2_stack[depth], 99)
    ax.imshow(c2_stack[depth,], 'gray', vmin=vmin, vmax=vmax)
    #ax.set_xlim((200, 1500))
    ax.set_axis_off()

PV

video
In [8]:
YouTubeVideo("xYVKVBjvGKE")
Out[8]:
figure
In [54]:
root = ET.fromstring(bioformats.get_omexml_metadata(path="C:/Users/kiritani/Documents/data/cells/TK577/Anatomy/stack_tdtom_586p92-730p22.lsm"))
nsmap = {'n': 'http://www.openmicroscopy.org/Schemas/OME/2015-01'}
pixels = root.find('n:Image', namespaces=nsmap).find('n:Pixels', namespaces=nsmap)
pixelsize = dict(x=pixels.get('PhysicalSizeX'), y=pixels.get('PhysicalSizeY'), z=pixels.get('PhysicalSizeZ'))

The following imagej macro was used to rotate the original confocal image and save the data in .ome.tif.

open("C:\\Users\\kiritani\\Documents\\data\\cells\\TK577\\Anatomy\\normalized_stack_tdtom.ome.tif");
run("Rotate... ", "angle=45 grid=1 interpolation=Bilinear enlarge stack");
run("Reslice [/]...", "output=0.6251697 start=Top");
run("Rotate... ", "angle=-9 grid=1 interpolation=Bilinear enlarge stack");
run("Reslice [/]...", "output=0.6251697 start=Top");
run("Bio-Formats Exporter", "save=C:\\Users\\kiritani\\Documents\\data\\cells\\TK577\\Anatomy\\normalized_rotated_stack_tdtom.ome.tif
export compression=Uncompressed");

In [41]:
fig = plt.figure(figsize=(6.85, 10))
gs1 = gridspec.GridSpec(1, 3, left=0.05, right=1, bottom=0.7, wspace=0, hspace=0)
ax_l4_large = fig.add_subplot(gs1[0, :-1])
ax_l4_large.imshow(L4barrels[0, 0, 1, :, :], 'gray', vmin=0, vmax=57)
ax_l4_large.set_ylim((2000, 1000))
ax_whisker_pad = fig.add_subplot(gs1[0, -1])
ax_whisker_pad.imshow(whisker_pad)
ax_whisker_pad.text(640, 700, r'$\alpha$', color='r')
ax_whisker_pad.text(650, 800, r'$\beta$', color='r')
ax_whisker_pad.text(750, 730, 'B1', color='r')
ax_whisker_pad.text(880, 690, 'B2', color='r')
ax_whisker_pad.text(960, 660, 'B3', color='r')
ax_whisker_pad.text(1080, 620, 'B4', color='r')
ax_whisker_pad.set_xlim((500, 1500))
ax_whisker_pad.set_ylim(top=200)
ax_whisker_pad.set_axis_off()
ax_side_view = fig.add_axes([0.07, 0, 0.3, 0.6], )
ax_side_view.imshow(c2_stack[:, :, 700], 'gray',)
ax_side_view.set_xlim((500, 1100))
ax_side_view.yaxis.tick_right()
ax_side_view.yaxis.set_tick_params(direction='in', pad=0)
depths = [373, 704, 1005, 1260, 1464, 1755]
pia = 250
ax_side_view.set_yticks(depths)
ax_side_view.set_yticklabels(['<' for i in range(len(depths))], color='r')
ax_side_view.axhline(pia, color='r')
##ax_side_view.yaxis.t = 0
gs2 = gridspec.GridSpec(3, 2, top=0.65, left=0.4, right=1, hspace=0.03, wspace=0.01)
for i, depth in enumerate(depths):
    ax = fig.add_subplot(gs2[i%3, i >2])
    ax.imshow(rotate(c2_stack[depth], 45)[700:1500, 800:1500], 'gray')
    ax.set_axis_off()
distribution in 3d
In [11]:
barrel_projection = np.max(barrel, axis=0)
In [67]:
voxel_size_um3 = np.prod(list(pixel_size.values()))
np.sum(barrel==124) * voxel_size_um3
for neuron in zip(x_neurons, y_neurons, z_neurons):
    neuron_Pixel
if barrel[x_neurons / pixel_size['x'], y_neurons / pixel_size['y'], z_neurons / pixel_size['z']]==124:
    the neuron is barrel neuron
  File "<ipython-input-67-226d5c498465>", line 4
    the neuron is barrel neuron
             ^
SyntaxError: invalid syntax
Mouse TK578
video
In [12]:
c2_stack_raw = tifffile.imread("C:/Users/kiritani/Documents/data/cells/TK578/Anatomy/Concatenated Stacks.tif")[:, :, :, 0]
anim = stack2movie(c2_stack_raw, step_size=2.9, pia=43)
anim.save('TK578.mp4', writer='ffmpeg', bitrate=100000, dpi=300)
In [84]:
YouTubeVideo("vWB09ONEWAk")
Out[84]:
figure
In [82]:
fig, gs1, ax_l4_large, ax_whisker_pad, ax_side_view, gs2 = prepare_fig()

ax_l4_large.imshow(L4barrels[0, 0, 1, :, :], 'gray', vmin=0, vmax=37)
ax_l4_large.set_ylim((2000, 1000))
ax_whisker_pad.imshow(whisker_pad)
ax_whisker_pad.text(640, 700, r'$\alpha$', color='r')
ax_whisker_pad.text(650, 800, r'$\beta$', color='r')
ax_whisker_pad.text(750, 730, 'B1', color='r')
ax_whisker_pad.text(880, 690, 'B2', color='r')
ax_whisker_pad.text(960, 660, 'B3', color='r')
ax_whisker_pad.text(1080, 620, 'B4', color='r')
ax_whisker_pad.set_xlim((500, 1500))
ax_whisker_pad.set_ylim(top=250)
ax_side_view.imshow(c2_stack[170:, 600, :], 'gray', vmin=0, vmax=60)
ax_side_view.set_xlim((500, 1100))
ax_side_view.yaxis.set_tick_params(direction='in', pad=0)
depths = [333, 643, 1146, 1287, 1415, 2044]
vmins = [0, 0, 0, 0, 0, 0]
vmaxes = [25, 30, 30, 30, 30, 30]
ax_side_view.set_yticks(depths)
ax_side_view.set_yticklabels(['<' for i in range(len(depths))], color='r')
for i, depth in enumerate(depths):
    ax = fig.add_subplot(gs2[i%3, i >2])
    ax.imshow(rotate(c2_stack[depth], -17)[300:1300, 450:1400], 'gray', vmin=vmins[i], vmax=vmaxes[i])
    ax.set_axis_off()
distribution in 3d
Mouse TK579
video
In [10]:
YouTubeVideo("YmBbFV7tuuQ")
Out[10]:
figure
In [112]:
fig, gs1, ax_l4_large, ax_whisker_pad, ax_side_view, gs2 = prepare_fig()

ax_l4_large.imshow(np.rot90(L4barrels[0, 0, 1, :, :], 3), 'gray', vmin=0, vmax=26)
ax_l4_large.set_xlim((1500, 3500))
ax_l4_large.set_ylim((1500, 200))
ax_whisker_pad.imshow(whisker_pad)
ax_whisker_pad.text(640, 670, r'$\alpha$', color='r')
ax_whisker_pad.text(650, 800, r'$\beta$', color='r')
ax_whisker_pad.text(750, 700, 'B1', color='r')
ax_whisker_pad.text(880, 650, 'B2', color='r')
ax_whisker_pad.text(960, 590, 'B3', color='r')
ax_whisker_pad.text(1040, 550, 'B4', color='r')
ax_whisker_pad.set_xlim((500, 1150))
ax_whisker_pad.set_ylim((900, 400))
ax_side_view.imshow(c2_stack[0,0,:, 600, :], 'gray', vmin=0, vmax=30)
ax_side_view.set_aspect(voxel_size['z'] / voxel_size['x'])
ax_side_view.set_xlim(left=400)
ax_side_view.yaxis.set_tick_params(direction='in', pad=0)
depths = [36, 110, 179, 215, 237, 323]
vmins = [0, 0, 0, 0, 0, 0]
vmaxes = [25, 30, 30, 30, 30, 30]
ax_side_view.set_yticks(depths)
ax_side_view.set_yticklabels(['<' for i in range(len(depths))], color='r')
for i, depth in enumerate(depths):
    ax = fig.add_subplot(gs2[i%3, i >2])
    ax.imshow(c2_stack[0, 0, depth, :, :], 'gray', vmin=vmins[i], vmax=vmaxes[i])
    ax.set_axis_off()
distribution in 3d

Som

same analysis

Mouse TK553
In [2]:
L4barrel = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK0553/Anatomy/tile456um_from_surface.lsm');
td_2p_image = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK0553/Anatomy/stack_tdtomato_980nm_001.tif');
tdtom = td_2p_image[::2]
dapi_2p_image = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK0553/Anatomy/stack_dapi_800nm_001.tif');
L4_tdtom_confo_stack = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK0553/Anatomy/tdtomato_stack_around_c2.lsm');
L4_green_confo_stack = tifffile.imread('C:/Users/kiritani/Documents/data/cells/TK0553/Anatomy/autofluorescence_stack_around_c2.lsm');

First, confocal image of L4 was acquired.

In [29]:
f, axarr = plt.subplots(1, 2)
axarr[0].imshow(L4barrel[0, 0, 0, :, :], 'gray')
axarr[0].set_title('Green fluorescence in L4')
axarr[1].imshow(L4barrel[0, 0, 1, :, :], 'gray', vmax=30)
axarr[1].set_title('tdTomato fluorescence in L4')

#axarr[1, 0].imshow(td_2p_image[572, :, :], 'gray')
#axarr[1, 1].imshow(L4_tdtom_confo_stack[0, 0, 9, :, :], 'gray')
Out[29]:
<matplotlib.text.Text at 0xe212e6d7f0>

Then, the whole C2 barrel was imaged with Angeliki's 2p microscope.

In [58]:
f, axarr = plt.subplots(5, 2, figsize=(10,20))
axarr[0, 0].imshow(td_2p_image[400, :, :], 'gray', vmax=1000)
axarr[0, 0].set_title('tdtom in L2/3')
axarr[0, 1].imshow(dapi_2p_image[401, :, :], 'gray', vmax=1000)
axarr[0, 1].set_title('dapi in L2/3')

axarr[1, 0].imshow(td_2p_image[600, :, :], 'gray', vmax=1000)
axarr[1, 0].set_title('tdtom in L4')
axarr[1, 1].imshow(dapi_2p_image[601, :, :], 'gray', vmax=1000)
axarr[1, 1].set_title('dapi in L4')

axarr[2, 0].imshow(td_2p_image[800, :, :], 'gray', vmax=1000)
axarr[2, 0].set_title('tdtom in L2/3')
axarr[2, 1].imshow(dapi_2p_image[801, :, :], 'gray', vmax=1000)
axarr[2, 1].set_title('dapi in L2/3')

axarr[4, 1].imshow(dapi_2p_image[0::2,:,400],'gray')
axarr[4, 1].set_aspect(2)

Finally, the C2 barrel was imaged under the Leica confocal microscope. The barrels and septa are easy to see. The 2p image and confocal image were superimposed.

In [4]:
f, axarr = plt.subplots(3, 2, figsize=(10,20))
L4_tdtom_2p_slice = td_2p_image[582, :, :] 
axarr[0, 0].imshow(L4_tdtom_2p_slice, 'gray', vmax=1000)
axarr[0, 0].set_title('tdtom in L4')

L4_tdtom_confo_slice = L4_tdtom_confo_stack[0, 0, 9, : ,:]
axarr[0, 1].imshow(L4_tdtom_confo_slice, 'gray', vmin=0, vmax=150)

axarr[1, 0].imshow(L4_tdtom_2p_slice, 'gray', vmax=1000)
axarr[1, 0].set_title('tdtom in L4')

L4_tdtom_confo_slice = L4_tdtom_confo_stack[0, 0, 9, : ,:]

transformed = np.zeros((1024, 1024))
h = 950
w = 900
transformed[39:h + 39, 47:w + 47] = rotate(zoom(L4_tdtom_confo_slice, (1.97, 2.03)), 95.8)[100:h + 100, 0:w]
axarr[1, 1].imshow(transformed, 'gray', vmin=0, vmax=150)
axarr[2, 1].imshow(transformed, 'gray', vmin=0, vmax=150)
super_imposed = np.dstack((L4_tdtom_2p_slice, transformed, np.zeros((1024, 1024))))
super_imposed[:, :, 0] = super_imposed[:, :, 0] / 1000
super_imposed[:, :, 1] = super_imposed[:, :, 1] / 100
axarr[2, 0].imshow(super_imposed,)
Out[4]:
<matplotlib.image.AxesImage at 0x4ce3b60ac8>

The C2 barrel region and the septum around the C2 were manually selected in imagej.

In [6]:
with open("C:/Users/kiritani/Documents/data/cells/TK0553/Anatomy/septum.roi", "rb") as f:
    septum_roi = ijroi.read_roi(f)
    
with open("C:/Users/kiritani/Documents/data/cells/TK0553/Anatomy/barrel.roi", "rb") as f:
    barrel_roi = ijroi.read_roi(f)
In [10]:
f, axarr = plt.subplots(3, 2, figsize=(10,20))
#L4_tdtom_2p_slice = td_2p_image[576, :, :] 
#axarr[0, 0].imshow(L4_tdtom_2p_slice, 'gray', vmax=1000)
#axarr[0, 0].set_title('tdtom in L4')


L4_green_confo_slice = L4_green_confo_stack[0, 0, 20, : ,:]
transformed_green = np.zeros((1024, 1024))
transformed_green[39:h + 39, 47:w + 47] = rotate(zoom(L4_green_confo_slice, (1.97, 2.03)), 95.9)[100:h + 100, 0:w]
axarr[0, 0].imshow(transformed_green, 'gray', )
axarr[0, 1].imshow(transformed_green, 'gray', )
import scipy.misc
scipy.misc.imsave('outfile.jpg', transformed_green)
from matplotlib.patches import Polygon
barrel = Polygon(barrel_roi[:, ::-1], alpha=0.3)
axarr[0, 1].add_patch(barrel)

septum = Polygon(septum_roi[:, ::-1], alpha=0.3)

axarr[0, 1].add_patch(septum);
In [24]:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

# create a 21 x 21 vertex mesh
xx, yy = np.meshgrid(np.linspace(0,1,1024), np.linspace(0,1,1024))

# create vertices for a rotated mesh (3D rotation matrix)
X =  xx 
Y =  yy
Z =  10*np.ones(X.shape)


data = tdtom[300]

# create the figure
fig = plt.figure()

# show the reference image
ax1 = fig.add_subplot(121)
ax1.imshow(data, cmap=plt.cm.BrBG, interpolation='nearest', origin='lower', extent=[0,1,0,1])

# show the 3D rotated projection
ax2 = fig.add_subplot(122, projection='3d')
ax2.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=plt.cm.BrBG(data), shade=False)
#ax2.plot_surface(X, Y, Z+0.1, rstride=1, cstride=1, facecolors=plt.cm.BrBG(data), shade=False, alpha=0.2, linewidth=0)
#ax2.plot_surface(X, Y, Z+0.2, rstride=1, cstride=1, facecolors=plt.cm.BrBG(data), shade=False, alpha=0.2, linewidth=0)
Mouse TK573
In [198]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK573/Anatomy/whisker_pad/MC120055.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(670, 820, r'$\alpha$', color='red')
plt.text(920, 710, 'B1', color='red')
plt.text(1030, 620, 'B2', color='red')
plt.text(1140, 550, 'B3', color='red')
plt.text(1240, 515, 'B4', color='red')
plt.xlim((500, 1500))
Out[198]:
(500, 1500)
Mouse TK574
In [197]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK574/Anatomy/whisker_pad/MC120053.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(1000, 700, r'$\alpha$', color='red')
plt.text(1080, 700, 'B1', color='red')
plt.text(1150, 680, 'B2', color='red')
plt.text(1240, 665, 'B3', color='red')
plt.text(1340, 655, 'B4', color='red')
plt.xlim((700, 1500))
Out[197]:
(700, 1500)
Mouse TK575
video
In [10]:
YouTubeVideo("YmBbFV7tuuQ")
Out[10]:
In [93]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK575/Anatomy/whisker_pad/MC120057.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(900, 520, r'$\alpha$', color='red')
plt.text(900, 580, r'$\beta$', color='red')
plt.text(980, 540, 'B0', color='red')
plt.text(1050, 515, 'B1', color='red')
plt.text(1120, 500, 'B2', color='red')
plt.text(1190, 475, 'B3', color='red')
plt.xlim((700, 1500))
Out[93]:
(700, 1500)
Mouse TK594
video
In [4]:
path = "C:/Users/kiritani/Documents/data/cells/TK594/Anatomy/stack_tdtom.czi"
root = ET.fromstring(bioformats.get_omexml_metadata(path=path))
nsmap = {'n': 'http://www.openmicroscopy.org/Schemas/OME/2015-01'}
voxel = root.find('n:Image', namespaces=nsmap).find('n:Pixels', namespaces=nsmap)
voxel_size = dict(x=float(voxel.get('PhysicalSizeX')), y=float(voxel.get('PhysicalSizeY')), z=float(voxel.get('PhysicalSizeZ')))
c2_stack_raw = np.array([bioformats.load_image(path, z=z, c=0, rescale=False) for z in range(int(voxel.get('SizeZ')))])
In [49]:
YouTubeVideo('veQegLcYaS4')
Out[49]:
figure
In [9]:
path = 'C:/Users/kiritani/Documents/data/cells/TK594/Anatomy/tile500um_green.czi'
root = ET.fromstring(bioformats.get_omexml_metadata(path=path))
nsmap = {'n': 'http://www.openmicroscopy.org/Schemas/OME/2015-01'}
pixel = root.find('n:Image', namespaces=nsmap).find('n:Pixels', namespaces=nsmap)
pixel_size = dict(x=float(pixel.get('PhysicalSizeX')), y=float(pixel.get('PhysicalSizeY')), )
L4barrels = bioformats.load_image(path, z=0, c=0, rescale=False)
In [22]:
voxel_size
Out[22]:
{'x': 0.5189161381023994, 'y': 0.5189161381023994, 'z': 3.3252871811561553}
In [43]:
fig, gs1, ax_l4_large, ax_whisker_pad, ax_side_view, gs2 = prepare_fig()

ax_l4_large.imshow(rotate(L4barrels, -40), 'gray', vmin=30, vmax=135)
ax_l4_large.set_ylim((2150, 1500))
ax_l4_large.set_xlim((850, 2250))
ax_whisker_pad = fig.add_subplot(gs1[0, -1])
ax_whisker_pad.imshow(whisker_pad)

ax_whisker_pad.text(650, 570, r'$\alpha$', color='red')
ax_whisker_pad.text(550, 650, r'$\beta$', color='red')
ax_whisker_pad.text(700, 650, 'B1', color='red')
ax_whisker_pad.text(800, 650, 'B2', color='red')
ax_whisker_pad.text(910, 650, 'B3', color='red')
ax_whisker_pad.text(970, 650, 'B4', color='red')
ax_whisker_pad.set_xlim((500, 1050))
ax_whisker_pad.set_ylim((900, 400))
#ax_whisker_pad.text(640, 700, r'$\alpha$', color='r')
#ax_whisker_pad.text(650, 800, r'$\beta$', color='r')
#ax_whisker_pad.text(750, 730, 'B1', color='r')
#ax_whisker_pad.text(880, 690, 'B2', color='r')
#ax_whisker_pad.text(960, 660, 'B3', color='r')
#ax_whisker_pad.text(1080, 620, 'B4', color='r')
#ax_whisker_pad.set_xlim((500, 1500))
#ax_whisker_pad.set_ylim(top=200)
#ax_whisker_pad.set_axis_off()
#ax_side_view = fig.add_axes([0.07, 0, 0.3, 0.6], )
ax_side_view.imshow(c2_stack_raw[:, :, 700], 'gray', aspect=voxel_size['z'] / voxel_size['x'], vmin=0, vmax=150)
#ax_side_view.set_xlim((500, 1100))
ax_side_view.yaxis.tick_right()
ax_side_view.yaxis.set_tick_params(direction='in', pad=0)
depths = [21, 91, 163, 200, 277, 338]
#pia = 250
ax_side_view.set_yticks(depths)
ax_side_view.set_yticklabels(['<' for i in range(len(depths))], color='r')
#ax_side_view.axhline(pia, color='r')

for i, depth in enumerate(depths):
    ax = fig.add_subplot(gs2[i%3, i >2])
    ax.imshow(c2_stack_raw[depth], 'gray')
    ax.set_axis_off()
In [12]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK594/Anatomy/whisker_pad/MC120061.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(650, 570, r'$\alpha$', color='red')
plt.text(550, 650, r'$\beta$', color='red')
plt.text(700, 650, 'B1', color='red')
plt.text(800, 650, 'B2', color='red')
plt.text(910, 650, 'B3', color='red')
plt.text(970, 650, 'B4', color='red')
plt.xlim((400, 1100))
plt.ylim((1000, 200))
Out[12]:
(1000, 200)
Mouse TK595
video
In [44]:
path = "C:/Users/kiritani/Documents/data/cells/TK595/Anatomy/stack_tdtom0-1400p18.czi"
root = ET.fromstring(bioformats.get_omexml_metadata(path=path))
nsmap = {'n': 'http://www.openmicroscopy.org/Schemas/OME/2015-01'}
voxel = root.find('n:Image', namespaces=nsmap).find('n:Pixels', namespaces=nsmap)
voxel_size = dict(x=float(voxel.get('PhysicalSizeX')), y=float(voxel.get('PhysicalSizeY')), z=float(voxel.get('PhysicalSizeZ')))
c2_stack_raw = np.array([bioformats.load_image(path, z=z, c=0, rescale=False) for z in range(int(voxel.get('SizeZ')))])
In [50]:
YouTubeVideo('bUrhbymZsB4')
Out[50]:
figure
In [9]:
path = 'C:/Users/kiritani/Documents/data/cells/TK594/Anatomy/tile500um_green.czi'
root = ET.fromstring(bioformats.get_omexml_metadata(path=path))
nsmap = {'n': 'http://www.openmicroscopy.org/Schemas/OME/2015-01'}
pixel = root.find('n:Image', namespaces=nsmap).find('n:Pixels', namespaces=nsmap)
pixel_size = dict(x=float(pixel.get('PhysicalSizeX')), y=float(pixel.get('PhysicalSizeY')), )
L4barrels = bioformats.load_image(path, z=0, c=0, rescale=False)
In [22]:
voxel_size
Out[22]:
{'x': 0.5189161381023994, 'y': 0.5189161381023994, 'z': 3.3252871811561553}
In [43]:
fig, gs1, ax_l4_large, ax_whisker_pad, ax_side_view, gs2 = prepare_fig()

ax_l4_large.imshow(rotate(L4barrels, -40), 'gray', vmin=30, vmax=135)
ax_l4_large.set_ylim((2150, 1500))
ax_l4_large.set_xlim((850, 2250))
ax_whisker_pad = fig.add_subplot(gs1[0, -1])
ax_whisker_pad.imshow(whisker_pad)

ax_whisker_pad.text(650, 570, r'$\alpha$', color='red')
ax_whisker_pad.text(550, 650, r'$\beta$', color='red')
ax_whisker_pad.text(700, 650, 'B1', color='red')
ax_whisker_pad.text(800, 650, 'B2', color='red')
ax_whisker_pad.text(910, 650, 'B3', color='red')
ax_whisker_pad.text(970, 650, 'B4', color='red')
ax_whisker_pad.set_xlim((500, 1050))
ax_whisker_pad.set_ylim((900, 400))
#ax_whisker_pad.text(640, 700, r'$\alpha$', color='r')
#ax_whisker_pad.text(650, 800, r'$\beta$', color='r')
#ax_whisker_pad.text(750, 730, 'B1', color='r')
#ax_whisker_pad.text(880, 690, 'B2', color='r')
#ax_whisker_pad.text(960, 660, 'B3', color='r')
#ax_whisker_pad.text(1080, 620, 'B4', color='r')
#ax_whisker_pad.set_xlim((500, 1500))
#ax_whisker_pad.set_ylim(top=200)
#ax_whisker_pad.set_axis_off()
#ax_side_view = fig.add_axes([0.07, 0, 0.3, 0.6], )
ax_side_view.imshow(c2_stack_raw[:, :, 700], 'gray', aspect=voxel_size['z'] / voxel_size['x'], vmin=0, vmax=150)
#ax_side_view.set_xlim((500, 1100))
ax_side_view.yaxis.tick_right()
ax_side_view.yaxis.set_tick_params(direction='in', pad=0)
depths = [21, 91, 163, 200, 277, 338]
#pia = 250
ax_side_view.set_yticks(depths)
ax_side_view.set_yticklabels(['<' for i in range(len(depths))], color='r')
#ax_side_view.axhline(pia, color='r')

for i, depth in enumerate(depths):
    ax = fig.add_subplot(gs2[i%3, i >2])
    ax.imshow(c2_stack_raw[depth], 'gray')
    ax.set_axis_off()

VIP

Mouse TK568
In [163]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK568/Anatomy/whisker_pad/MC120054.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(740, 610, r'$\alpha$', color='red')
plt.text(680, 780, r'$\beta$', color='red')
plt.text(870, 730, 'B1', color='red')
plt.text(1080, 690, 'B2', color='red')
plt.text(1280, 690, 'B3', color='red')
plt.text(1420, 690, 'B4', color='red')
plt.xlim((300, 1500))
Out[163]:
(300, 1500)
Mouse TK569
In [148]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK569/Anatomy/whisker_pad/MC120060.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(740, 700, r'$\alpha$', color='red')
plt.text(680, 800, r'$\beta$', color='red')
plt.text(800, 810, 'B1', color='red')
plt.text(920, 740, 'B2', color='red')
plt.text(1040, 640, 'B3', color='red')
plt.xlim((500, 1500))
Out[148]:
(500, 1500)
Mouse TK570
In [139]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK570/Anatomy/whisker_pad/MC120053.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(700, 680, r'$\alpha$', color='red')
plt.text(680, 780, r'$\beta$', color='red')
plt.text(800, 740, 'B1', color='red')
plt.text(960, 690, 'B2', color='red')
plt.text(1140, 640, 'B3', color='red')
plt.text(1240, 620, 'B4', color='red')
plt.xlim((500, 1500))
Out[139]:
(500, 1500)
Mouse TK572
In [127]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK572/Anatomy/whisker_pad/MC120054.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(700, 630, r'$\alpha$', color='red')
plt.text(700, 730, r'$\beta$', color='red')
plt.text(780, 700, 'B1', color='red')
plt.text(860, 690, 'B2', color='red')
plt.text(950, 680, 'B3', color='red')
plt.xlim((100, 1500))
Out[127]:
(100, 1500)

Tlx1

Mouse TK583
In [5]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK583/Anatomy/whisker_pad/MC120055.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(700, 480, r'$\alpha$', color='red')
plt.text(650, 630, r'$\beta$', color='red')
plt.text(780, 580, 'B1', color='red')
plt.text(940, 550, 'B2', color='red')
plt.text(1100, 530, 'B3', color='red')
plt.xlim((100, 1500))
Out[5]:
(100, 1500)

Sim1

TK584
In [11]:
whiskpad = mpimg.imread("C:/Users/kiritani/Documents/data/cells/TK584/Anatomy/whisker_pad/MC120058.JPG")
plt.figure()
plt.imshow(whiskpad)
plt.title('whisker pad')
plt.text(780, 560, r'$\alpha$', color='red')
plt.text(760, 740, r'$\beta$', color='red')
plt.text(890, 620, 'B1', color='red')
plt.text(1000, 600, 'B2', color='red')
plt.text(1140, 590, 'B3', color='red')
plt.xlim((100, 1500))
Out[11]:
(100, 1500)
In [23]:
%%HTML
<h3>Scnn1a mouse, recovery of a neuron</h3>
<video controls>
  <source src="data/images/TK497/slice4_stack.mp4.mp4" type="video/mp4">
</video>

Scnn1a mouse, recovery of a neuron

In [204]:
display(HTML("<h3>A small summary of my experiments</h3>"))

cellsScnn = (pickle.load(open(file,'rb')) for file in glob.glob("data/free_whisking/tdTomatoScnn1a/*.pickle"))
cellsScnn = (cell for cell in cellsScnn if cell['id'] not in remove_these_cells_Scnn)
pipette_R_Scnn = []
miceScnn = []
rec_durs = []
for cell in cellsScnn:
    pipette_R_Scnn.append(cell['pipette_resistance'])
    miceScnn.append(cell['mouse_id'])
    rec_durs.extend([rec['df'].index[-1] for rec in cell['recordings']])

miceScnn = np.unique(miceScnn)

cellsPV = [pickle.load(open(file,'rb')) for file in glob.glob("data/free_whisking/tdTomatoPV/*.pickle")]
cellsPV = [cell for cell in cellsPV if cell['id'] not in remove_these_cells_PV]
pipette_R_PV = [cell['pipette_resistance'] for cell in cellsPV]
micePV = [cell['mouse_id'] for cell in cellsPV]
micePV = np.unique(micePV)
for cell  in cellsPV:
    rec_durs.extend([rec['df'].index[-1] for rec in cell['recordings']])

cellsSom = [pickle.load(open(file,'rb')) for file in glob.glob("data/free_whisking/tdTomatoSom/*.pickle")]
cellsSom = [cell for cell in cellsSom if cell['id'] not in remove_these_cells_Som]
pipette_R_SOM = [cell['pipette_resistance'] for cell in cellsSom]
miceSom = [cell['mouse_id'] for cell in cellsSom]
miceSom = np.unique(miceSom)
for cell  in cellsSom:
    rec_durs.extend([rec['df'].index[-1] for rec in cell['recordings']])

cellsVIP = [pickle.load(open(file,'rb')) for file in glob.glob("data/free_whisking/tdTomatoVIP/*.pickle")]
cellsVIP = [cell for cell in cellsVIP if cell['id'] not in remove_these_cells_VIP]
pipette_R_VIP = [cell['pipette_resistance'] for cell in cellsVIP]
miceVIP = [cell['mouse_id'] for cell in cellsVIP]
miceVIP = np.unique(miceVIP)
for cell  in cellsVIP:
    rec_durs.extend([rec['df'].index[-1] for rec in cell['recordings']])

pipette_R = pipette_R_Scnn + pipette_R_PV + pipette_R_SOM + pipette_R_VIP
display(HTML('<p>pipette R: {} - {} MOhm</p>'.format(min(pipette_R), max(pipette_R))))
print('mean: {} MOhm, std: {}'.format(np.mean(pipette_R), np.std(pipette_R)))

mice = miceScnn + micePV + miceSom + miceVIP
print('num of mice: {}'.format(len(mice)))

total_rec_dur = sum(rec_durs)
print('total recording duration: {}'.format(total_rec_dur))

A small summary of my experiments

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-204-2053fa7ed78f> in <module>()
      2 
      3 cellsScnn = (pickle.load(open(file,'rb')) for file in glob.glob("data/free_whisking/tdTomatoScnn1a/*.pickle"))
----> 4 cellsScnn = [cell for cell in cellsScnn if cell['id'] not in remove_these_cells_Scnn]
      5 pipette_R_Scnn = [cell['pipette_resistance'] for cell in cellsScnn]
      6 miceScnn = [cell['mouse_id'] for cell in cellsScnn]

<ipython-input-204-2053fa7ed78f> in <listcomp>(.0)
      2 
      3 cellsScnn = (pickle.load(open(file,'rb')) for file in glob.glob("data/free_whisking/tdTomatoScnn1a/*.pickle"))
----> 4 cellsScnn = [cell for cell in cellsScnn if cell['id'] not in remove_these_cells_Scnn]
      5 pipette_R_Scnn = [cell['pipette_resistance'] for cell in cellsScnn]
      6 miceScnn = [cell['mouse_id'] for cell in cellsScnn]

NameError: name 'remove_these_cells_Scnn' is not defined
In [12]:
def channelnorm(im, channel, vmin, vmax):
    c = (im[:, :, channel] - vmin) / (vmax - vmin)
    c[c < 0.] = 0
    c[c > 1.] = 1
    im[:, :, channel] = c
    return im

f, axarr = plt.subplots(5, 2, figsize=(12, 20))
image = tifffile.imread('data/images/TK504/Anatomy/slice8_epi_tdtomato/Fused.tif')
axarr[0, 0].imshow(np.fliplr(image), cmap='gray',)
axarr[0, 0].set_title('epi tdtom')

image = tifffile.imread('data/images/TK504/Anatomy/slice8_epi_farred/Fused.tif')
axarr[0, 1].imshow(np.fliplr(image), cmap='gray', vmin=0, vmax=68)
axarr[0, 1].set_title('epi alexa 647')

image = tifffile.imread('data/images/TK504/Anatomy/slice8_stack40x.lsm')
frame = image[0, 51, :, :, :]
frame = np.rollaxis(frame, 0, 3)
frame = frame.astype(float)
channelnorm(frame, 0, 0, 255)
channelnorm(frame, 1, 1, 255)
channelnorm(frame, 2, 1, 100)
axarr[1, 0].imshow(frame[:, :, ::-1])
axarr[1, 0].set_title('confocal Zoomed')

axarr[1, 1].imshow(frame[450:850, 400:800, ::-1], vmin=100, vmax=3000)
axarr[1, 1].set_title('Zoomed more')

image = tifffile.imread('data/images/TK504/AAAA/patched920_004.tif')
image = np.append(image, np.zeros((1, 256, 256)), axis=0)
image = np.rollaxis(image, 0, 3)
channelnorm(image, 0, -148, -106)
channelnorm(image, 1, -158, 150)
axarr[2, 0].imshow(rotate(image[:, :, [1, 0, 2]], -55))
axarr[2, 0].set_title('2p in vivo')

image = tifffile.imread('data/images/TK504/Anatomy/slice8_stack40x.lsm')
frame = image[0, 46, :, :, :] # or 41
frame = np.rollaxis(frame, 0, 3)
frame = frame.astype(float)
channelnorm(frame, 0, 0, 255)
channelnorm(frame, 1, 1, 150)
channelnorm(frame, 2, 1, 100)
axarr[3, 0].imshow(frame[:, :, ::-1])
axarr[3, 0].set_title('Zoomed')

axarr[3, 1].imshow(frame[350:850, 200:700, ::-1], vmin=100, vmax=3000)
axarr[3, 1].set_title('Zoomed more')

image = tifffile.imread('data/images/TK504/AAAC/patched920_006.tif')
image = np.append(image, np.zeros((1, 128, 128)), axis=0)
image = np.rollaxis(image, 0, 3)
channelnorm(image, 0, -148, -106)
channelnorm(image, 1, -158, 140)
axarr[4, 0].imshow(rotate(image[:, :, [1, 0, 2]], -55))
axarr[4, 0].set_title('2p in vivo');
print('these guys are C1 neurons')
In [15]:
f, axarr = plt.subplots(5, 2, figsize=(12, 20))

image = tifffile.imread('data/images/TK499/slice7_epi_tdTomato_Fused.tif')
image = np.flipud(image)
axarr[0, 0].imshow(image[:, 0:5500], cmap='gray')
pixel_size = 895.26 / 1388 # in um/pixel
bar200um = 200 / pixel_size
#plt.plot([3000, bar200um + 3000], [100, 100], color='w')
axarr[0, 0].set_title('Scnn1a TK499', color='brown')

confocal_stack = tifffile.imread('data/images/TK499/Image7_20x.lsm')
frame = confocal_stack[0, 18, :, :, :]
frame = np.rollaxis(frame, 0, 3)
frame = frame.astype(float)
channelnorm(frame, 0, 0, 255)
channelnorm(frame, 1, 1, 255)
channelnorm(frame, 2, 1, 255)
frame = np.flipud(frame)
axarr[0, 1].imshow(rotate(frame[:, :, ::-1], 150))
axarr[0, 1].set_title('C2 barrel, confocal')

image = tifffile.imread('data/images/TK499/Image7_20x.lsm')
frame = image[0, 31, :, :, :]
frame = np.rollaxis(frame, 0, 3)
frame = frame.astype(float)
channelnorm(frame, 0, 0, 255)
channelnorm(frame, 1, 1, 255)
channelnorm(frame, 2, 1, 100)
frame = np.flipud(frame)
axarr[1, 0].imshow(rotate(frame[:, :, ::-1], 150))
axarr[1, 0].set_title('C2 barrel, confocal')

axarr[1, 1].imshow(np.rot90(frame[300:800, 300:800, ::-1], 2))
axarr[1, 1].set_title('C2 barrel, confocal')

image = tifffile.imread('data/images/TK499/AAAA/patched920_001.tif')
image = np.append(image, np.zeros((1, 128, 128)), axis=0)
image = np.rollaxis(image, 0, 3)
channelnorm(image, 0, -148, -106)
channelnorm(image, 1, -158, 150)
axarr[2, 0].imshow(rotate(image[:, :, [1, 0, 2]], 140))
axarr[2, 0].set_title('2p in vivo')

frame = confocal_stack[0, 19, :, :, :]
frame = np.rollaxis(frame, 0, 3)
frame = frame.astype(float)
channelnorm(frame, 0, 0, 255)
channelnorm(frame, 1, 1, 60)
channelnorm(frame, 2, 1, 160)
axarr[3, 1].imshow(np.rot90(frame[:, :, ::-1], 2))
axarr[3, 1].set_title('C2 barrel, confocal')

image = tifffile.imread('data/images/TK499/AAAB/patched920_002.tif')
image = np.append(image, np.zeros((1, 128, 128)), axis=0)
image = np.rollaxis(image, 0, 3)
channelnorm(image, 0, -148, -106)
channelnorm(image, 1, -158, 150)
axarr[4, 0].imshow(rotate(image[:, :, [1, 0, 2]], 140))
axarr[4, 0].set_title('2p in vivo')

image = tifffile.imread('data/images/TK499/AAAC/patched920_003.tif')
image = np.append(image, np.zeros((1, 128, 128)), axis=0)
image = np.rollaxis(image, 0, 3)
channelnorm(image, 0, -148, -106)
channelnorm(image, 1, -158, 150)
axarr[4, 1].imshow(rotate(image[:, :, [1, 0, 2]], 140))
axarr[4, 1].set_title('2p in vivo')
print('these neurons are in C2');
Out[15]:
<matplotlib.text.Text at 0xbec2614710>
In [82]:
f, axarr = plt.subplots(6, 2, figsize=(12, 20))

image = tifffile.imread('data/images/TK496/slice8_epi_tdTomato/Fused.tif')
axarr[0, 0].imshow(np.rot90(image, 2), cmap='gray')
pixel_size = 895.26 / 1388 # in um/pixel
bar200um = 200 / pixel_size
#plt.plot([3000, bar200um + 3000], [100, 100], color='w')
axarr[0, 0].set_title('Scnn1a TK496', color='brown')

image = tifffile.imread('data/images/TK496/slice8_epi_farred/Fused.tif')
axarr[0, 1].imshow(np.rot90(image, 2), cmap='gray', vmin=0, vmax=40)
pixel_size = 895.26 / 1388 # in um/pixel
bar200um = 200 / pixel_size
#plt.plot([3000, bar200um + 3000], [100, 100], color='w')
axarr[0, 1].set_title('Scnn1a TK496', color='brown')

image = tifffile.imread('data/images/TK496/slice8_stack_tdtom_farred.lsm')
frame = image[0, 32, :, :, :]
frame = np.rollaxis(frame, 0, 3)
frame = frame.astype(float)
channelnorm(frame, 0, 0, 255)
channelnorm(frame, 1, 1, 255)
#frame = np.flipud(frame)
frame = np.append(frame, np.zeros(( 1024, 1024, 1)), axis=2)
axarr[1, 0].imshow(rotate(frame, 0))
axarr[1, 0].set_title('C2 barrel, confocal')

image = tifffile.imread('data/images/TK496/AAAA/patched920_002.tif')
#frame = image[0, 10, :, :, :]
image = np.rollaxis(image, 0, 3)
image = image.astype(float)
channelnorm(image, 0, -144, -130)
channelnorm(image, 1, -152, 193)
#frame = np.flipud(frame)
frame = np.append(image, np.zeros((128, 128, 1)), axis=2)
axarr[1, 1].imshow(rotate(frame, -40))
axarr[1, 1].set_title('C2 barrel, in vivo');

image = tifffile.imread('data/images/TK496/slice8_stack_tdtom_farred.lsm')
frame = image[0, 10, :, :, :]
frame = np.rollaxis(frame, 0, 3)
frame = frame.astype(float)
channelnorm(frame, 0, 0, 255)
channelnorm(frame, 1, 1, 255)
#frame = np.flipud(frame)
frame = np.append(frame, np.zeros(( 1024, 1024, 1)), axis=2)
axarr[3, 0].imshow(rotate(frame, 0))
axarr[3, 0].set_title('C2 barrel, confocal')

image = tifffile.imread('data/images/TK496/AAAB/patched920_004.tif')
#frame = image[0, 10, :, :, :]
image = np.rollaxis(image, 0, 3)
image = image.astype(float)
channelnorm(image, 0, -147, -139)
channelnorm(image, 1, -159, 50)
#frame = np.flipud(frame)
frame = np.append(image, np.zeros((256, 256, 1)), axis=2)
axarr[3, 1].imshow(rotate(frame, -40))
axarr[3, 1].set_title('C2 barrel, in vivo');

image = tifffile.imread('data/images/TK496/slice9_epi_tdTomato/Fused.tif')
axarr[4, 0].imshow(np.rot90(image, 2), cmap='gray')
pixel_size = 895.26 / 1388 # in um/pixel
bar200um = 200 / pixel_size
#plt.plot([3000, bar200um + 3000], [100, 100], color='w')
axarr[4, 0].set_title('Scnn1a TK496', color='brown')

image = tifffile.imread('data/images/TK496/slice9_epi_farred/Fused.tif')
axarr[4, 1].imshow(np.rot90(image, 2), cmap='gray', vmin=0, vmax=40)
pixel_size = 895.26 / 1388 # in um/pixel
bar200um = 200 / pixel_size
#plt.plot([3000, bar200um + 3000], [100, 100], color='w')
axarr[4, 1].set_title('Scnn1a TK496', color='brown');

image = tifffile.imread('data/images/TK496/slice9_stack_tdtom_farred.lsm')
frame = image[0, 87, :, :, :]
frame = np.rollaxis(frame, 0, 3)
frame = frame.astype(float)
channelnorm(frame, 0, 0, 255)
channelnorm(frame, 1, 1, 255)
#frame = np.flipud(frame)
frame = np.append(frame, np.zeros(( 1024, 1024, 1)), axis=2)
axarr[5, 0].imshow(rotate(frame, 0))
axarr[5, 0].set_title('C2 barrel, confocal')

image = tifffile.imread('data/images/TK496/AAAD/patched920_007.tif')
#frame = image[0, 10, :, :, :]
image = np.rollaxis(image, 0, 3)
image = image.astype(float)
channelnorm(image, 0, -147, -139)
channelnorm(image, 1, -159, 50)
#frame = np.flipud(frame)
frame = np.append(image, np.zeros((128, 128, 1)), axis=2)
axarr[5, 1].imshow(rotate(frame, -60))
axarr[5, 1].set_title('C2 barrel, in vivo');
In [57]:
frame = np.append(image, np.zeros((256, 256, 1)), axis=2)
In [36]:
image.shape
Out[36]:
(2, 256, 256)
In [ ]: